<template>
<div>
    
    <ButtonGroup>
        <Button type="primary" @click="addDate">添加数据</Button>
        <Button type="error" @click="removes">批量删除</Button>
    </ButtonGroup>
    <Input v-model="filter.name">
        <Button slot="append" icon="ios-search" @click="search"></Button>
    </Input>
    <Table border :columns="columns" :data="list" @on-selection-change="onSelectionChange"></Table>
    <Page :total="filter.total" :page-size="filter.rows" @on-change="onPagechange" @on-page-size-change="onPagesizechange" show-sizer ></Page>

    <Modal
        v-model="operateModal"
        title="数据处理"
        @on-cancel="cancel"
        >
        <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="80">
        <FormItem label="用户名" prop="name">
            <Input v-model="formValidate.name" placeholder="Enter your name"></Input>
        </FormItem>
        <FormItem label="密码" prop="password">
            <Input v-model="formValidate.password" placeholder="Enter your password"></Input>
        </FormItem>
        <FormItem label="性别" prop="sex">
            <Input v-model="formValidate.sex" placeholder="Enter your sex"></Input>
        </FormItem>
        <FormItem label="爱好" prop="hobby">
            <Input v-model="formValidate.hobby" placeholder="Enter your hobby"></Input>
        </FormItem>
        <FormItem label="联系电话" prop="phone">
            <Input v-model="formValidate.phone" placeholder="Enter your phone"></Input>
        </FormItem>
        <FormItem>
            <Button type="primary" @click="handleSubmit('formValidate')">Submit</Button>
            <Button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">Reset</Button>
        </FormItem>
        
        
    </Form>
    <div slot="footer">
           数据操作！
        </div>
    </Modal>
</div>
</template>
<script>
import {Base} from '../../common/Base.js'
    export default {
        mixins:[Base],
        data () {
            return {
                module:'users',
                formValidate: {
                    name: '',
                    password: '',
                    sex:'',
                    hobby:'',
                    phone:''
                },
                ruleValidate: {
                    name: [
                        { required: true, message: '用户名不能为空', trigger: 'blur' }
                    ],
                    password: [
                        { required: true, message: '密码不能为空', trigger: 'blur' },
                    ],
                    sex: [
                        { required: true, message: '性别不能为空', trigger: 'blur' }
                    ],
                    hobby: [
                        { required: true, message: '爱好不能为空', trigger: 'blur' }
                    ],
                    phone: [
                        { required: true, message: '联系电话不能为空', trigger: 'blur' }
                    ]
                   
                },
               
                columns: [
                    {
                        type: 'selection',
                        width: 60,
                        align: 'center'
                    },
                    {
                        title: '姓名',
                        key: 'name',
                        render: (h, params) => {
                            return h('div', [
                                h('Icon', {
                                    props: {
                                        type: 'person'
                                    }
                                }),
                                h('strong', params.row.name)
                            ]);
                        }
                    },
                   {
                        title: '性别',
                        key: 'sex'
                    },
                    {
                        title: '爱好',
                        key: 'hobby'
                    },
                     {
                        title: '联系电话',
                        key: 'phone'
                    },
                    {
                        title: '操作',
                        key: 'action',
                        width: 150,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            this.editDate(params)
                                        }
                                    }
                                }, '修改'),
                                h('Button', {
                                    props: {
                                        type: 'error',
                                        size: 'small'
                                    },
                                    on: {
                                        click: () => {
                                            this.remove(params)
                                        }
                                    }
                                }, '删除')
                            ]);
                        }
                    }
                ],
               
                
            }
        }
    }
</script>


